export const state = () => ({
    userInfo: {
        token: "",
        user: {},

    }

})

export const mutations = {
    setuser(state, data) {
        state.userInfo = data
        console.log(data);
    },
    removeUser(state) {
        state.userInfo = {}
    }
}



export const actions = {
    setuserInof(store, data) {
        return this.$axios({
            url: "/accounts/login",
            method: "post",
            data: data
        }).then(res => {
            // console.log(res.data);
            if (res.data.token) {
                store.commit("setuser", res.data);
                return res
            }
        })

    }
}